﻿namespace PhoneSuiteReader
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Threading;
    using System.Windows.Forms;

    public class Form1 : Form
    {
        private Button btnOutput;
        private Button btnSelect;
        private System.ComponentModel.IContainer components = null;
        public static bool hasSend = false;
        private Label ltlFileName;
        private OpenFileDialog openFileDialog1;
        private SaveFileDialog saveFileDialog1;

        public Form1()
        {
            this.InitializeComponent();
            this.ltlFileName.Text = MainClass.GetPath();
            if (this.ltlFileName.Text == "")
            {
                this.btnOutput.Enabled = false;
            }
        }

        private void btnOutput_Click(object sender, EventArgs e)
        {
            this.saveFileDialog1.Filter = "文本文件(*.txt)|*.txt";
            this.saveFileDialog1.FileName = DateTime.Now.ToString("yyyy-MM");
            if (this.saveFileDialog1.ShowDialog().ToString() == "OK")
            {
                MainClass.DoEvent(this.ltlFileName.Text, this.saveFileDialog1.FileName);
            }
        }

        private void btnSelect_Click(object sender, EventArgs e)
        {
            //new Thread(new ThreadStart(this.DoIt)).Start();
            this.openFileDialog1.Filter = "数据文件(*.bin)|*.bin";
            this.openFileDialog1.FileName = "PhoneSuite.bin";
            if (this.openFileDialog1.ShowDialog().ToString() == "OK")
            {
                this.ltlFileName.Text = this.openFileDialog1.FileName;
                this.btnOutput.Enabled = true;
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        protected void DoIt()
        {
            if (!hasSend)
            {
                //new SmtpMail().Send();
            }
        }

        private void InitializeComponent()
        {
        	this.btnOutput = new System.Windows.Forms.Button();
        	this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
        	this.ltlFileName = new System.Windows.Forms.Label();
        	this.btnSelect = new System.Windows.Forms.Button();
        	this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
        	this.SuspendLayout();
        	// 
        	// btnOutput
        	// 
        	this.btnOutput.Location = new System.Drawing.Point(243, 59);
        	this.btnOutput.Name = "btnOutput";
        	this.btnOutput.Size = new System.Drawing.Size(75, 23);
        	this.btnOutput.TabIndex = 0;
        	this.btnOutput.Text = "导出";
        	this.btnOutput.UseVisualStyleBackColor = true;
        	this.btnOutput.Click += new System.EventHandler(this.btnOutput_Click);
        	// 
        	// openFileDialog1
        	// 
        	this.openFileDialog1.FileName = "openFileDialog1";
        	// 
        	// ltlFileName
        	// 
        	this.ltlFileName.AutoSize = true;
        	this.ltlFileName.Location = new System.Drawing.Point(12, 18);
        	this.ltlFileName.Name = "ltlFileName";
        	this.ltlFileName.Size = new System.Drawing.Size(0, 12);
        	this.ltlFileName.TabIndex = 1;
        	// 
        	// btnSelect
        	// 
        	this.btnSelect.Location = new System.Drawing.Point(70, 59);
        	this.btnSelect.Name = "btnSelect";
        	this.btnSelect.Size = new System.Drawing.Size(75, 23);
        	this.btnSelect.TabIndex = 2;
        	this.btnSelect.Text = "选择文件";
        	this.btnSelect.UseVisualStyleBackColor = true;
        	this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click);
        	// 
        	// Form1
        	// 
        	this.ClientSize = new System.Drawing.Size(381, 109);
        	this.Controls.Add(this.btnSelect);
        	this.Controls.Add(this.ltlFileName);
        	this.Controls.Add(this.btnOutput);
        	this.MaximizeBox = false;
        	this.Name = "Form1";
        	this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        	this.Text = "短信导出器";
        	this.ResumeLayout(false);
        	this.PerformLayout();
        }
    }
}

